package org.example.ttms.controller;

import javafx.fxml.FXML;
import javafx.scene.control.TabPane;
import javafx.scene.layout.StackPane;
import org.example.ttms.Main;
import org.example.ttms.entityClass.User;

public class UserController {

    @FXML
    private TabPane tabPane;

    @FXML
    private StackPane stackPane;

    @FXML
    private StackPane stackPane2;

    @FXML
    private StackPane stackPane3;

    public static User user;

    public void initialize(){
        tabPane.getSelectionModel().selectedItemProperty().addListener((obs, oldTab, newTab) -> {
            if(oldTab.getText().trim().equals("购票")){
                stackPane.getChildren().clear();
                BuyTicketHostController.observableList.clear();
            }
            else if(oldTab.getText().trim().equals("订单")){
                stackPane2.getChildren().clear();
            }
            else if(oldTab.getText().trim().equals("个人中心")){
                stackPane3.getChildren().clear();
            }
            if(newTab.getText().trim().equals("购票")){
                Main.jumpPage2(stackPane, "buyTicketHost.fxml");
            }
            else if(newTab.getText().trim().equals("订单")){
                Main.jumpPage2(stackPane2, "order.fxml");
            }
            else if(newTab.getText().trim().equals("个人中心")){
                Main.jumpPage2(stackPane3, "userMessage.fxml");
            }
        });
    }

}
